package com.itmuch.contentcenter.feignclient.fallback;

import com.itmuch.contentcenter.domain.dto.user.UserDTO;
import com.itmuch.contentcenter.feignclient.UserCenterFeignClient;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class UserCenterFeignClientFallbackFactory implements FallbackFactory<UserCenterFeignClient> {


    @Override
    public UserCenterFeignClient create(Throwable throwable) {
        return new UserCenterFeignClientFallback(){
            @Override
            public UserDTO findById(Integer userId) {
                UserDTO userDTO = new UserDTO();
                log.warn(userDTO.toString(),throwable);
                userDTO.setWxNickname("被限流了factory");
                return userDTO;
            }

            @Override
            public UserDTO query(UserDTO userDTO) {
                return super.query(userDTO);
            }
        };
    }
}
